package com.qianying.controller.admin;

import com.qianying.comment.CommonResult;
import com.qianying.entity.CustomerContact;
import com.qianying.service.CustomerContactService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户主要联系人管理API
 *
 * @author check
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/admin/customerContact")
@Tag(name = "客户：主要联系人管理(客户/门店)")
public class CustomerContactController {

    @Autowired
    private CustomerContactService customerContactService;

    @PostMapping("/save") // 使用Service函数名，POST方法
    @Operation(summary = "添加客户主要联系人")
    public CommonResult<CustomerContact> save(@RequestBody CustomerContact entity) {
        return customerContactService.save(entity);
    }

    @PostMapping("/updateById") // 使用Service函数名，POST方法
    @Operation(summary = "更新客户主要联系人")
    public CommonResult<?> updateById(@RequestBody CustomerContact entity) {
        return customerContactService.updateById(entity);
    }

    @PostMapping("/removeById") // 使用Service函数名，POST方法
    @Operation(summary = "删除客户主要联系人")
    public CommonResult<?> removeById(@RequestParam Long id) {
        return customerContactService.removeById(id);
    }

    @GetMapping("/getById") // 使用Service函数名，GET方法
    @Operation(summary = "获取客户主要联系人详情")
    public CommonResult<CustomerContact> getById(@RequestParam Long id) {
        return customerContactService.getById(id);
    }

    @GetMapping("/getByCustomerId") // 使用Service函数名，GET方法
    @Operation(summary = "根据客户ID获取联系人列表")
    public CommonResult<List<CustomerContact>> getByCustomerId(@RequestParam Long customerId) {
        return customerContactService.getByCustomerId(customerId);
    }

}